<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>

<script>
var m = 120;
var n = 180;
var min = m < n ? m : n;
var greatestCommonDivisor;
for(; min >= 1; min--){
    if(m % min == 0 && n % min == 0){
        greatestCommonDivisor = min;
        break;
    }
}
console.log("最大公约数:" + greatestCommonDivisor);

var max = m > n ? m : n;
var leastCommonMultiple = max;
for(; true; max++){
    if(max % m == 0 && max % n == 0){
        leastCommonMultiple = max;
        break;
    }
}
console.log("最小公倍数:" + leastCommonMultiple);
</script>
</body>

</html>